<?php
namespace app\common\validate;
use think\Validate;
use think\Request;
class MemberCard extends Validate{
    protected $rule =   [
        'card'  => 'require',
        'cardtype' => 'require',
        // 'cardprov'=>'require',
        'cardcity'   => 'require',
        'agree' => 'require',
        'code' => 'require|checkCode',
    ];

    protected $message  =   [
        'card.require' => '银行卡号不为空',
        'cardtype.require' => '需要选择所属银行',
        'cardprov.require' => '需要选择开户所在地省份',
        'cardcity.require' => '开户地址不能为空',
        'agree.require' => '需要同意《用户协议》',
        'code.require' => '验证码不能为空！',
    ];

    protected $scene = [
        // 'update' => ['phone', 'username', 'password'],
    ];
    
    protected function checkCode($value, $rule=[], $data){
        $status = check_sms($data['phone'], $data['code']);
        if(!$status){
            return '验证码输入错误';
        }
        else{
            return true;
        }
    }
}